import {getCompanyOpt} from './api';
import moment from 'moment';
export const formItems = [
  {
    label: '优享汇ID',
    name: 'id',
    type: 'input-number',
    itemProps: {
      style: {width: '100%'}
    }
  },
  {
    label: '状态',
    name: 'status',
    span: 8,
    type: 'select',
    itemProps: {
      options: [
        {
          label: '上架',
          value: 'STATUS_PUT_SHELF',
        },
        {
          label: '下架',
          value: 'STATUS_OFF_SHELF',
        },
      ],
    },
  },
  {
    label: '创建日期',
    name: 'times',
    span: 8,
    valueFields: ['created_start_at', 'created_end_at'],
    valueType: 'number',
    value: [],
    type: 'range-picker',
    format: 'YYYY-MM-DD',
  }
];

export const searchRules = {

};

export const columns = [
  {
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    width: 80,
  },
  {
    title: '优享汇ID',
    dataIndex: 'id',
    key: 'id',
    width: 100,
  },
  {
    title: '二维码',
    dataIndex: 'url',
    key: 'url',
    width: 100,
    align: 'center',
    slots: { customRender: 'url' },
  },
  {
    title: '创建时间',
    dataIndex: 'create_time',
    key: 'create_time',
    width: 200,
    customRender(row) {
      return moment(row.text * 1000).format('YYYY-MM-DD k:mm:ss');
    },
  },
  {
    title: '状态',
    dataIndex: 'status_name',
    key: 'status_name',
    width: 100,
    customRender({text, record}) {
      const dict = {
        'STATUS_OFF_SHELF': '下架',
        'STATUS_PUT_SHELF': '上架'
      }
      return dict[record.status] || '-';
    }
  },
];
